package com.jingdianjichi.auth.domain.service.Impl;

import cn.dev33.satoken.secure.SaSecureUtil;
import com.alibaba.fastjson.JSON;
import com.jingdianjichi.auth.common.enums.AuthUserStatusEnum;
import com.jingdianjichi.auth.common.enums.IsDeletedFlagEnum;
import com.jingdianjichi.auth.domain.bo.AuthRoleBO;
import com.jingdianjichi.auth.domain.convert.AuthRoleBOConvert;
import com.jingdianjichi.auth.domain.convert.AuthUserBOConvert;
import com.jingdianjichi.auth.domain.service.AuthRoleDomainService;
import com.jingdianjichi.auth.infra.bastic.entity.AuthRole;
import com.jingdianjichi.auth.infra.bastic.entity.AuthUser;
import com.jingdianjichi.auth.infra.bastic.service.AuthRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * ClassName:AuthRoleDomainServiceImpl
 * Package:com.jingdianjichi.auth.domain.service.Impl
 * Description:
 *
 * @Author fst
 * @Create 2024/10/10 14:58
 * @Version 1.0
 */
@Slf4j
@Service
public class AuthRoleDomainServiceImpl implements AuthRoleDomainService
{

    @Resource
    private AuthRoleService authRoleService;

    public void add(AuthRoleBO authRoleBO)
    {
        if(log.isInfoEnabled())
        {
            log.info("AuthRoleDomainServiceImpl.add.Bo:{}", JSON.toJSONString(authRoleBO));
        }

        AuthRole authRole= AuthRoleBOConvert.INSTANCE.convertBOTORole(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());

        authRoleService.insert(authRole);
    }

    public  void update(AuthRoleBO authRoleBO)
    {
        if(log.isInfoEnabled())
        {
            log.info("AuthRoleDomainServiceImpl.add.Bo:{}", JSON.toJSONString(authRoleBO));
        }

        AuthRole authRole= AuthRoleBOConvert.INSTANCE.convertBOTORole(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());

        authRoleService.update(authRole);
    }


    public  void delete(AuthRoleBO authRoleBO)
    {
        if(log.isInfoEnabled())
        {
            log.info("AuthRoleDomainServiceImpl.add.Bo:{}", JSON.toJSONString(authRoleBO));
        }

        AuthRole authRole= AuthRoleBOConvert.INSTANCE.convertBOTORole(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());

        authRoleService.delete(authRole);
    }


}
